package com.sc.nft.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sc.nft.mapper.DigitalCollectionProductInfoFreeSubscribeMapper;
import com.sc.nft.entity.DigitalCollectionProductInfoFreeSubscribe;
import com.sc.nft.service.DigitalCollectionProductInfoFreeSubscribeService;
import org.springframework.stereotype.Service;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 免费申购码获取条件(DigitalCollectionProductInfoFreeSubscribe)表Dao层
 *
 * @author 王伟成
 * @since 2024-05-14 10:20:33
 */
@Slf4j
@Repository
public class DigitalCollectionProductInfoFreeSubscribeDao extends ServiceImpl<DigitalCollectionProductInfoFreeSubscribeMapper, DigitalCollectionProductInfoFreeSubscribe> {

    public List<DigitalCollectionProductInfoFreeSubscribe> getDigitalCollectionProductInfoFreeSubscribeAdmin(Long id) {
        LambdaQueryWrapper<DigitalCollectionProductInfoFreeSubscribe> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(DigitalCollectionProductInfoFreeSubscribe::getProductId, id);
        return baseMapper.selectList(wrapper);
    }
    public void removeByProductId(Long id) {
        LambdaUpdateWrapper<DigitalCollectionProductInfoFreeSubscribe> wrapper = Wrappers.lambdaUpdate();
        wrapper.eq(DigitalCollectionProductInfoFreeSubscribe::getProductId,id);
        remove(wrapper);
    }
}
